package com.annotation.demo1;

/**
 * @ClassName Student
 * @Description 创建一个学生类，有姓名和年龄两个字段，
 * 使用上面定义的注解设置年龄不能低于18岁，否则抛出异常
 * @Author Kx
 * @Date 2025/3/28 11:28
 * @Version 1.0
 */
public class Student {
    private String name;

    @MyAnnotation(age = 18)
    private int age;

    public Student() {}

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
        try {
            AnnotationProcessor.validate(this);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
